﻿//https://ac.nowcoder.com/acm/problem/223985
#include <iostream>  
using namespace std;
typedef long long LL;

int main() {
    LL a, h, b, k;
    cin >> a >> h >> b >> k;
    LL ret = 0;
    while (h > 0 && k > 0) {
        h -= b;
        k -= a;
        ret += a + b;
    }

    if (h <= 0 && k <= 0) {
        cout << ret << endl;
    }
    else if (h <= 0) {
        cout << ret + b * 10 << endl;
    }
    else if (k <= 0) {
        cout << ret + a * 10 << endl;
    }
    else {
        cout << ret << endl;
    }

    return 0;
}





//https://www.nowcoder.com/practice/1718131e719746e9a56fb29c40cc8f95?tpId=230&tqId=39753&ru=/exam/oj
#include <algorithm>  
#include <iostream>  
#include <vector>  
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    long long sum = a[0];
    long long cur = a[0];

    for (int i = 1; i < n; i++) {
        cur = max(a[i], cur + a[i]);
        sum = max(sum, cur);
    }

    cout << sum << endl;
    return 0;
}

//https://ac.nowcoder.com/acm/problem/214851

#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int fun()
{
    // 1. 判断是否全都是相同字符
    bool flag = false;
    for (int i = 1; i < n; i++)
    {
        if (s[i] != s[0])
        {
            flag = true;
            break;
        }
    }
    if (flag == false) return 0;
    // 2. 判断本⾝是否是回⽂
    flag = true;
    int left = 0, right = n - 1;
    while (left < right)
    {
        if (s[left] == s[right])
        {
            left++;
            right--;
        }
        else
        {
            flag = false;
            break;
        }
    }
    if (flag) return n - 1;
    else return n;
}
int main()
{
    cin >> s;
    n = s.size();
    cout << fun() << endl;
    return 0;
}